#import "dfhgwhruebvhrheytransportmortalViewController.h"
#import "dfhgwhruebvhrheydizzycurveViewController.h"
#import "dfhgwhruebvhrheyconnectionencounterViewController.h"
@interface dfhgwhruebvhrheyconnectionencounterViewController ()<UIScrollViewDelegate>
@property (nonatomic, strong) dfhgwhruebvhrheytransportmortalViewController *cashVC;
@property (nonatomic, strong) dfhgwhruebvhrheydizzycurveViewController *bankVC;
@property (nonatomic, strong) dfhgwhruebvhrheydizzycurveViewController *e_walletVC;
@end
@implementation dfhgwhruebvhrheyconnectionencounterViewController {
	UIView *bgView;
	UIView *methodView;
	UIButton *e_walletBtn;
	UIButton *cashBtn;
	UIButton *bankBtn;
	UIButton *lastBtn;
	UIView *line;
	UIScrollView *contentView;
	UIView *containerView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
	[self loadUI];
}
- (void)loadUI {
	[self configBackIcon:@"dhgfywegwygeydwcurvereciprocal"];
	[self configRightIcon:@"navigation_right"];
	self.navigationStyle = dhgfywegwygeydwreciprocaltransport;
	self.navigationItem.title = @"Withdrawal method";
	bgView = [[UIView alloc] init];
	bgView.backgroundColor = [UIColor whiteColor];
	[self.view addSubview:bgView];
	methodView = [[UIView alloc] init];
	methodView.backgroundColor = primary_color.dhgfywegwygeydwlearneddesignate;
	[self.view addSubview:methodView];
	e_walletBtn = [UIButton buttonWithType:UIButtonTypeCustom];
	e_walletBtn.tag = 100;
	e_walletBtn.selected = YES;
	e_walletBtn.titleLabel.font = [UIFont semiBold:15];
	[e_walletBtn setTitle:@"E-Wallet" forState:UIControlStateNormal];
	[e_walletBtn setTitleColor:white_color.dhgfywegwygeydwlearneddesignate forState:UIControlStateNormal];
	[e_walletBtn setTitleColor:second_color.dhgfywegwygeydwlearneddesignate forState:UIControlStateSelected];
	[methodView addSubview:e_walletBtn];
	[e_walletBtn addTarget:self action:@selector(methodBtnsClick:) forControlEvents:UIControlEventTouchUpInside];
	cashBtn = [UIButton buttonWithType:UIButtonTypeCustom];
	cashBtn.tag = 101;
	cashBtn.titleLabel.font = [UIFont semiBold:15];
	[cashBtn setTitle:@"Cash" forState:UIControlStateNormal];
	[cashBtn setTitleColor:white_color.dhgfywegwygeydwlearneddesignate forState:UIControlStateNormal];
	[cashBtn setTitleColor:second_color.dhgfywegwygeydwlearneddesignate forState:UIControlStateSelected];
	[methodView addSubview:cashBtn];
	[cashBtn addTarget:self action:@selector(methodBtnsClick:) forControlEvents:UIControlEventTouchUpInside];
	bankBtn = [UIButton buttonWithType:UIButtonTypeCustom];
	bankBtn.tag = 102;
	bankBtn.titleLabel.font = [UIFont semiBold:15];
	[bankBtn setTitle:@"BankCard" forState:UIControlStateNormal];
	[bankBtn setTitleColor:white_color.dhgfywegwygeydwlearneddesignate forState:UIControlStateNormal];
	[bankBtn setTitleColor:second_color.dhgfywegwygeydwlearneddesignate forState:UIControlStateSelected];
	[methodView addSubview:bankBtn];
	[bankBtn addTarget:self action:@selector(methodBtnsClick:) forControlEvents:UIControlEventTouchUpInside];
	lastBtn = e_walletBtn;
	line = [[UIView alloc] init];
	line.layer.cornerRadius = 1.5;
	line.backgroundColor = second_color.dhgfywegwygeydwlearneddesignate;
	[methodView addSubview:line];
	contentView = [[UIScrollView alloc] init];
	contentView.pagingEnabled = YES;
	contentView.bounces = NO;
	contentView.delegate = self;
	contentView.showsHorizontalScrollIndicator = NO;
	[self.view addSubview:contentView];
	containerView = [[UIView alloc] init];
	containerView.backgroundColor = [UIColor whiteColor];
	[contentView addSubview:containerView];
	self.e_walletVC = [[dfhgwhruebvhrheydizzycurveViewController alloc] initWithStyle:dhgfywegwygeydwexaggeratesemester];
	self.e_walletVC.seletedTerm = self.seletedTerm;
	self.e_walletVC.isInner = YES;
	self.e_walletVC.selectedAmount = self.selectedAmount;
	[self addChildViewController:self.e_walletVC];
	[containerView addSubview:self.e_walletVC.view];
	self.cashVC = [[dfhgwhruebvhrheytransportmortalViewController alloc] init];
	self.cashVC.seletedTerm = self.seletedTerm;
	self.cashVC.selectedAmount = self.selectedAmount;
	[self addChildViewController:self.cashVC];
	[containerView addSubview:self.cashVC.view];
	self.bankVC = [[dfhgwhruebvhrheydizzycurveViewController alloc] initWithStyle:dhgfywegwygeydwsemesterfurious];
	self.bankVC.seletedTerm = self.seletedTerm;
	self.bankVC.isInner = YES;
	self.bankVC.selectedAmount = self.selectedAmount;
	[self addChildViewController:self.bankVC];
	[containerView addSubview:self.bankVC.view];
}
- (void)methodBtnsClick:(UIButton *)sender {
	if (sender == lastBtn) return;
	sender.selected = YES;
	lastBtn.selected = NO;
	lastBtn = sender;
	switch (sender.tag) {
		case 100: {
			[contentView setContentOffset:CGPointMake(0, 0) animated:YES];
		}
			break;
		case 101:{
			[contentView setContentOffset:CGPointMake(dhgfywegwygeydwdispositionvisualize, 0) animated:YES];
		}
			break;
		case 102: {
			[contentView setContentOffset:CGPointMake(2*dhgfywegwygeydwdispositionvisualize, 0) animated:YES];
		}
			break;
		default:
			break;
	}
}
- (void)viewDidLayoutSubviews {
	[super viewDidLayoutSubviews];
	[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop).offset(22);
		make.left.right.equalTo(self.view);
		make.height.mas_equalTo(27);
	}];
	[methodView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
		make.left.right.equalTo(self.view);
		make.height.mas_equalTo(54);
	}];
	[e_walletBtn mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.centerY.equalTo(methodView);
		make.height.mas_equalTo(38);
		make.width.equalTo(cashBtn);
	}];
	[cashBtn mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.equalTo(e_walletBtn.mas_right);
		make.centerY.height.equalTo(e_walletBtn);
		make.width.equalTo(bankBtn);
	}];
	[bankBtn mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.equalTo(cashBtn.mas_right);
		make.right.equalTo(methodView);
		make.width.height.centerY.equalTo(cashBtn);
	}];
	[line mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.mas_equalTo((dhgfywegwygeydwdispositionvisualize / 3 - 20)/2).priorityHigh();
		make.size.mas_equalTo(CGSizeMake(20, 3));
		make.bottom.equalTo(methodView).offset(-5);
	}];
	[contentView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.top.equalTo(methodView.mas_bottom).offset(5);
		make.left.bottom.right.equalTo(self.view);
	}];
	[containerView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.edges.equalTo(contentView);
		make.height.mas_equalTo(contentView);
	}];
	[self.e_walletVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
		make.top.left.bottom.equalTo(containerView);
		make.width.mas_equalTo(dhgfywegwygeydwdispositionvisualize);
	}];
	[self.cashVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.equalTo(self.e_walletVC.view.mas_right);
		make.top.bottom.equalTo(containerView);
		make.width.mas_equalTo(dhgfywegwygeydwdispositionvisualize);
	}];
	[self.bankVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.equalTo(self.cashVC.view.mas_right);
		make.top.bottom.equalTo(containerView);
		make.width.mas_equalTo(dhgfywegwygeydwdispositionvisualize);
		make.right.equalTo(containerView);
	}];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
	[line mas_updateConstraints:^(MASConstraintMaker *make) {
		make.left.mas_equalTo((dhgfywegwygeydwdispositionvisualize / 3 - 20)/2 + scrollView.contentOffset.x/3);
	}];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
	NSInteger tag = scrollView.contentOffset.x/dhgfywegwygeydwdispositionvisualize;
	UIButton *methodBtn = [methodView viewWithTag:100 + tag];
	[self methodBtnsClick:methodBtn];
}
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
	NSInteger tag = scrollView.contentOffset.x/dhgfywegwygeydwdispositionvisualize;
	UIButton *methodBtn = [methodView viewWithTag:100 + tag];
	[self methodBtnsClick:methodBtn];
}
@end
